import * as PIXI from "pixi.js";
import { App } from "../system/App";
import { TimerTxt } from "@/components/pages/game/ball/comp/game/TimerTxt";

export class Timer {
  constructor() {
    this.x = App.config.timer.x;
    this.y = App.config.timer.y;
    this.width = App.config.timer.width;
    this.height = App.config.timer.height;

    this.createContainer();
    this.createSprite();
    this.createTxt();
  }

  createContainer(x) {
    this.container = new PIXI.Container();
    this.container.x = this.x;
    this.container.y = this.y;
  }

  createSprite() {
    const sprite = App.sprite("timer");
    sprite.x = 0;
    sprite.y = 0;
    sprite.width = this.width;
    sprite.height = this.height;
    this.container.addChild(sprite);
  }

  createTxt() {
    this.txt = new TimerTxt();
    this.container.addChild(this.txt);
  }

  updateTimer(str) {
    this.txt.renderTimer(str)
  }
}